<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">资质类型</label>
                        <div class="layui-input-block">
                            <div id="engintype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">建设单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="jian_unit" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">所在地</label>
                        <div class="layui-input-block">
                            <input type="text" name="areas" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">业务对接人</label>
                        <div class="layui-input-block">
                            <input type="text" name="man_xiang_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>




    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('项目资金台账');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_tai_zijin_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                xmselect_dan('engintype', res.data.engintype, res.data.is_engintype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })



                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);


                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'name',title:'项目名称',fixed:'left',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: 'chanid_name', title: '项目所属单位'}
                ,{field: 'number', title: '项目编号'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field: 'lian_unit', title: '委托方'}
                ,{field: 'gonghuifee', title: '累计工程回款(元)',totalRow: true,align:'right',event: 'income_engin_gong',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.gonghuifee)+'</span>';
                    }}
                ,{field: 'incomeenginfee', title: '累计收款金额(元) A',totalRow: true,align:'right',event: 'income_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.incomeenginfee)+'</span>';
                    }}
                ,{field: 'payenginfee', title: '累计付款(元) B',totalRow: true,align:'right',event: 'payment_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.payenginfee)+'</span>';
                    }}
                ,{field: 'payenginfee_shen', title: '其中审核中付款(元)',totalRow: true,align:'right',event: 'payment_engin_shen',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.payenginfee_shen)+'</span>';
                    }}
                ,{field: 'paybaofee', title: '累计项目费用报销(元)',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.paybaofee)+'</span>';
                    }}
                ,{field: 'neikoufee', title: '累计扣款(元) C',totalRow: true,align:'right',event: 'tai_neiming',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.neikoufee)+'</span>';
                    }}
                ,{field: 'payment_xiangfu', title: '累计结算支付(元) D',totalRow: true,align:'right',event: 'payment_xiangfu',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.payment_xiangfu)+'</span>';
                    }}
                ,{field: 'balance', title: '项目余额(元) A-B-C-D',totalRow: true,align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.balance)+'</span>';
                    }}
                ,{field: 'leikoudai', title: '累计待扣(元)',totalRow: true,align:'right',event: 'engin_kou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.leikoudai)+'</span>';
                    }}
                ,{field: 'shengjiefee', title: '项目可用余额(元)',totalRow: true,align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.shengjiefee)+'</span>';
                    }}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'income_engin_gong'){
                openNavPage('项目工程回款信息','income_engin/index.php?enginid='+data.id+'&status=1&gongkuan=1');
            }
            if(obj.event === 'income_engin'){
                openNavPage('项目收款信息','income_engin/index.php?enginid='+data.id+'&status=1');
            }
            if(obj.event === 'payment_engin'){
                openNavPage('项目付款信息','payment_engin/index.php?enginid='+data.id);
            }
            if(obj.event === 'payment_engin_shen'){
                openNavPage('项目付款信息','payment_engin/index.php?enginid='+data.id+'&status=0');
            }

            if(obj.event === 'payment_bao'){
                openNavPage('项目费用报销信息','payment_bao/index.php?enginid='+data.id+'&status=1');
            }


            if(obj.event === 'tai_neiming'){
                openNavPage('扣款登记明细信息','tai_neiming/index.php?enginid='+data.id+'&status=1');
            }
            if(obj.event === 'engin_kou'){
                openNavPage('应扣费用表','engin_kou/index.php?enginid='+data.id+'&status=1');
            }
            if(obj.event === 'payment_xiangfu'){
                openNavPage('累计结算支付','payment_xiangfu/index.php?enginid='+data.id);
            }
        });


        listTableSearch(form, table);
    });



</script>
</body>
</html>
